package phase2.view;

import java.util.Map;

import oracle.adf.model.BindingContext;
import oracle.adf.view.rich.component.rich.input.RichInputText;

import oracle.binding.BindingContainer;
import oracle.binding.OperationBinding;

public class MenuBean
{
  private RichInputText currentPassword;
  private RichInputText newPassword;
  private RichInputText passwordConfirmation;

  public MenuBean()
  {
  }

  public void setCurrentPassword(RichInputText currentPassword)
  {
    this.currentPassword = currentPassword;
  }

  public RichInputText getCurrentPassword()
  {
    return currentPassword;
  }

  public String changePassword()
  {
    BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
    OperationBinding operation = bindings.getOperationBinding("validatePassword");
    Map param = operation.getParamsMap();
    param.put("oldPassword", this.currentPassword.getValue().toString());
    param.put("newPassword", this.newPassword.getValue().toString());
    param.put("confirmPassword", this.passwordConfirmation.getValue().toString());
    Boolean result = (Boolean)operation.execute();

    return null;
  }

  public void setNewPassword(RichInputText newPassword)
  {
    this.newPassword = newPassword;
  }

  public RichInputText getNewPassword()
  {
    return newPassword;
  }

  public void setPasswordConfirmation(RichInputText passwordConfirmation)
  {
    this.passwordConfirmation = passwordConfirmation;
  }

  public RichInputText getPasswordConfirmation()
  {
    return passwordConfirmation;
  }
}
